import { get, post } from "@/utils/request";
import type { ApiResponse, User, UserSearchResult } from "@/types";

/**
 * 获取用户信息
 */
export const getUserInfo = (): Promise<ApiResponse<User>> => {
  return get("/users/info");
};

/**
 * 更新用户信息
 */
export const updateUserInfo = (
  data: Partial<User>
): Promise<ApiResponse<User>> => {
  return post("/users/update", data);
};

/**
 * 搜索用户
 * @param email 用户邮箱
 * @returns 用户搜索结果
 */
export const searchUsers = (
  email: string
): Promise<ApiResponse<UserSearchResult>> => {
  return get(`/users/search?email=${email}`);
};
